package vip.fuxk.blog.config;

import com.github.xiaoymin.knife4j.solon.extension.OpenApiExtensionResolver;

import org.noear.solon.annotation.Bean;
import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Inject;
import org.noear.solon.docs.DocDocket;
import org.noear.solon.docs.models.ApiContact;
import org.noear.solon.docs.models.ApiInfo;
import org.noear.solon.docs.models.ApiScheme;
import vip.fuxk.blog.common.R;

@Configuration
public class DocConfig {

    // knife4j 的配置，由它承载
    @Inject
    OpenApiExtensionResolver openApiExtensionResolver;

    /**
     * 简单点的
     */
    @Bean("front")
    public DocDocket appApi() {
        //根据情况增加 "knife4j.setting" （可选）
        return new DocDocket()
                .basicAuth(openApiExtensionResolver.getSetting().getBasic())
                .vendorExtensions(openApiExtensionResolver.buildExtensions())
                .groupName("前台接口")
                .info(new ApiInfo().title("前台接口_在线文档")
                        .description("前台接口_在线API文档")
                        .termsOfService("https://gitee.com/noear/solon")
                        .contact(new ApiContact().name("demo")
                                .url("https://gitee.com/noear/solon")
                                .email("demo@foxmail.com"))
                        .version("1.0"))
                .schemes(ApiScheme.HTTP.toValue())
                .apis("vip.fuxk.blog.front.controller");

    }

    /**
     * 丰富点的
     */
    @Bean("admin")
    public DocDocket adminApi() {
        //根据情况增加 "knife4j.setting" （可选）
        return new DocDocket()
                .basicAuth(openApiExtensionResolver.getSetting().getBasic())
                .vendorExtensions(openApiExtensionResolver.buildExtensions())
                .groupName("后台接口")
                .info(new ApiInfo().title("后台接口_在线文档")
                        .description("后台接口_在线API文档")
                        .termsOfService("https://gitee.com/noear/solon")
                        .contact(new ApiContact().name("demo")
                                .url("https://gitee.com/noear/solon")
                                .email("demo@foxmail.com"))
                        .version("1.0"))
                .schemes(ApiScheme.HTTP.toValue(), ApiScheme.HTTPS.toValue())
                .globalResponseInData(true)
                .globalResult(R.class)
                .apis("com.swagger.demo.controller.admin"); //可以加多条，以包名为单位

    }
}